﻿/** \file
* \$Rev: 186 $
* 
* \$Date: 2010-04-16 05:58:01 +0000 (Fri, 16 Apr 2010) $
*
* \$URL: http://chorus-twitter.googlecode.com/svn/trunk/src/net/SearchSource.cs $
*/

using System;
using chorus.twitter;

namespace chorus.net
{
	/// <summary>
	/// A source that fetches statuses from the results of a search.
	/// </summary>
	public class StatusSource_Search :
		JsonMessageSource<statuses>
	{
		/// <summary>Restricts tweets to the given language, given by an ISO 639-1 code.</summary>
		public QueryParameter<string> lang = new QueryParameter<string>("lang");
		/// <summary>Specify the language of the query you are sending (only ja is currently effective).</summary>
		public QueryParameter<string> locale = new QueryParameter<string>("locale");
		/// <summary>The text to search for.</summary>
		public QueryParameter<string> query = new QueryParameter<string>("q");
		/// <summary>The number of tweets to return per page, up to a max of 100.</summary>
		public QueryParameter<uint> rpp = new QueryParameter<uint>("rpp");
		/// <summary>The page number (starting at 1) to return, up to a max of roughly 1500 results (based on rpp * page).</summary>
		public QueryParameter<uint> page = new QueryParameter<uint>("page");
		/// <summary>Returns tweets with status ids greater than the given id.</summary>
		public QueryParameter<ulong> since_id = new QueryParameter<ulong>("since_id");
		/// <summary>Returns tweets with status ids less than the given id.</summary>
		public QueryParameter<ulong> max_id = new QueryParameter<ulong>("max_id");
		/// <summary>Returns tweets with since the given date.  Date should be formatted as YYYY-MM-DD.</summary>
		public QueryParameter<string> since = new QueryParameter<string>("since");
		/// <summary>Returns tweets with generated before the given date.  Date should be formatted as YYYY-MM-DD.</summary>
		public QueryParameter<string> until = new QueryParameter<string>("until");
		/// <summary>
		/// Returns tweets by users located within a given radius of the given
		/// latitude/longitude.  The location is preferentially taking from the
		/// Geotagging API, but will fall back to their Twitter profile. The
		/// parameter value is specified by "latitide,longitude,radius", where
		/// radius units must be specified as either "mi" (miles) or "km"
		/// (kilometers).
		/// </summary>
		public QueryParameter<string> geocode = new QueryParameter<string>("geocode");
		/// <summary>
		/// Specifies what type of search results you would prefer to receive.
		/// Valid values include:
		///		mixed: In a future release this will become the default value. 
		///			Include both popular and real time results in the response.
		///		recent: The current default value. Return only the most recent 
		///			results in the response.
		///		popular: Return only the most popular results in the response.
		/// </summary>
		public QueryParameter<string> result_type = new QueryParameter<string>("result_type");

		/// <summary>The path part of the source URI.</summary>
		public override string UriPath { get { return "search"; } }

		/// <summary></summary>
		public StatusSource_Search()
		{
			qparams.Add(lang);
			qparams.Add(locale);
			qparams.Add(query);
			qparams.Add(rpp);
			qparams.Add(page);
			qparams.Add(since_id);
			qparams.Add(max_id);
			qparams.Add(since);
			qparams.Add(until);
			qparams.Add(geocode);
			qparams.Add(result_type);
		}

		/// <summary>The URI for the source.</summary>
		public override UriBuilder Uri
		{
			get
			{
				UriBuilder builder = base.Uri;
				builder.Scheme = "http";
				builder.Host = "search.twitter.com";
				return builder;
			}
		}
	}
}
